from sqlalchemy.orm import Session
from app.db.models import User
from app.core.security import get_password_hash

def init_default_data(db: Session):
    # 检查是否已存在管理员用户
    admin = db.query(User).filter(User.code == "yuand").first()
    if not admin:
        # 创建默认管理员用户
        admin_user = User(
            code="yuand",
            name="yuand",
            password=get_password_hash("123"),  # 默认密码，建议首次登录后修改
            email="xkcyy@outlook.com",
        )
        db.add(admin_user)
        db.commit()
        print("已创建默认管理员用户") 